package com.dd.service;

import com.dd.entity.User;
import com.dd.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * ProjectName: springMvc01->UserServiceImpl
 * Description: TODO：
 * Author: 丘丘
 * DateTime: 2024/12/27 14:15
 */
@Service  // 这个创建要创建Bean，表明愿意被IOC接管
public class UserServiceImpl implements UserService{
    // service 依赖于 mapper ，要把mapper自动装配
    @Autowired
    private UserMapper userMapper;

    @Override
    public List<User> selectAllUsers() {
        return userMapper.selectAllUsers();
    }

    @Override
    public User selectUserById(int id) {
        return userMapper.selectUserById(id);
    }

    @Override
    public int deleteUserById(int id) {
        return userMapper.deleteUserById(id);
    }

    @Override
    public int insertUser(User user) {
        return userMapper.insertUser(user);
    }

    @Override
    public int updateUser(User user) {
        return userMapper.updateUser(user);
    }

    @Override
    public List<User> selectUserByName(String username) {
        return userMapper.selectUserByName(username);
    }
}
